; Music of Mega Phoenix (1991) (Dinamic)
; Ripped by Megachur the 23/08/2008

	write "MEGAPHOE.BIN"

music_date_rip	equ &1788
music_adr	equ &3944
first_theme	equ 0
last_theme	equ 0	; 0 -> 0

	read "music_header_v1_0.asm"

;#3944
.l394b equ $ + 7
.l394a equ $ + 6
.l3949 equ $ + 5
.l3948 equ $ + 4
.l3947 equ $ + 3
.l3946 equ $ + 2
.l3945 equ $ + 1
.l3944
	db #00,#07,#08,#ff,#ff,#00,#00,#4d
	db #39,#84,#00,#b7,#00,#f9,#00,#00
	db #01,#02,#04,#05,#02,#06,#07,#02
	db #04,#05,#02,#06,#07,#02,#04,#05
	db #02,#06,#07,#02,#0b,#0c,#0d,#10
	db #11,#02,#13,#14,#15,#18,#19,#02
	db #13,#14,#1b,#18,#19,#02,#13,#14
	db #1b,#20,#19,#02,#23,#24,#25,#27
	db #19,#02,#2a,#2b,#1b,#2d,#19,#02
	db #2a,#2b,#30,#2d,#19,#02,#2a,#2b
	db #33,#20,#19,#02,#23,#24,#37,#38
	db #39,#3a,#3b,#3c,#3d,#40,#41,#42
	db #44,#45,#46,#48,#49,#4a,#4d,#45
	db #46,#4f,#50,#51,#53,#54,#55,#57
	db #49,#4a,#5a,#45,#5b,#5d,#49,#4a
	db #44,#45,#5b,#48,#49,#4a,#4d,#45
	db #46,#4f,#50,#51,#64,#54,#55,#57
	db #49,#4a,#5a,#45,#46,#69,#6a,#3a
	db #6b,#6c,#3d,#03,#08,#08,#09,#0a
	db #0e,#0f,#12,#16,#17,#1a,#1c,#1d
	db #1e,#1f,#21,#22,#26,#28,#29,#2c
	db #2e,#2f,#31,#32,#34,#35,#36,#3e
	db #3f,#43,#47,#4b,#4c,#4e,#52,#56
	db #58,#59,#5c,#5e,#5f,#60,#61,#62
.l3a08 equ $ + 4
	db #63,#65,#66,#67,#68,#6d,#48,#3a
	db #65,#3a,#76,#3a,#87,#3a,#a4,#3a
	db #c1,#3a,#e2,#3a,#f7,#3a,#0c,#3b
	db #21,#3b,#2e,#3b,#3d,#3b,#4c,#3b
	db #5b,#3b,#7c,#3b,#99,#3b,#be,#3b
	db #e7,#3b,#1a,#3c,#97,#3c,#ca,#3c
	db #e9,#3c,#0a,#3d,#25,#3d,#4a,#3d
	db #8d,#3d,#b6,#3d,#db,#3d,#f0,#3d
	db #6d,#3e,#8e,#3e,#0e,#9f,#69,#9d
	db #69,#9b,#69,#9a,#68,#96,#67,#98
	db #67,#9b,#66,#9f,#66,#9b,#65,#99
	db #65,#96,#64,#92,#65,#8a,#63,#82
	db #63,#08,#e0,#fe,#e0,#fe,#e0,#fc
	db #e0,#fa,#e0,#f9,#e0,#f9,#e0,#f8
	db #e0,#f8,#08,#e5,#fe,#e5,#fe,#e5
	db #fc,#e5,#fa,#e5,#f9,#e5,#f9,#e5
	db #f8,#e5,#f8,#0e,#9f,#6f,#9d,#6f
	db #9b,#6f,#9a,#6e,#96,#6d,#98,#6d
	db #9b,#6c,#9f,#6c,#9b,#6b,#99,#6b
	db #96,#6a,#92,#6a,#8a,#69,#82,#69
	db #0e,#80,#6f,#80,#6f,#80,#6f,#80
	db #6f,#80,#6d,#80,#6d,#80,#6b,#80
	db #6b,#80,#6a,#80,#6a,#80,#69,#80
	db #69,#80,#68,#80,#67,#90,#1e,#f0
	db #1f,#e0,#20,#d0,#21,#c0,#22,#b0
	db #23,#b0,#24,#a0,#25,#a0,#26,#90
	db #27,#90,#28,#80,#29,#80,#2a,#70
	db #2b,#70,#2c,#60,#2d,#60,#8a,#6b
	db #f3,#be,#f3,#83,#f4,#e5,#f4,#61
	db #f5,#bd,#f5,#53,#f6,#dc,#e6,#18
	db #d7,#b0,#c7,#8a,#00,#f2,#8b,#f2
	db #2d,#f3,#c5,#f3,#11,#f4,#7f,#f4
	db #3f,#f5,#83,#e5,#05,#d6,#55,#c6
	db #8a,#61,#f1,#c6,#f1,#7b,#f2,#e7
	db #f2,#5f,#f3,#af,#f3,#81,#f4,#db
	db #e4,#3f,#d5,#a3,#c5,#86,#32,#d0
	db #8a,#d0,#33,#d0,#8b,#d0,#32,#d0
	db #8a,#d0,#07,#90,#bf,#90,#bf,#90
	db #bf,#90,#bd,#90,#b9,#90,#b5,#90
	db #b1,#07,#90,#1f,#90,#1f,#90,#1f
	db #90,#1e,#90,#1a,#90,#15,#90,#12
	db #07,#50,#df,#50,#df,#50,#df,#50
	db #de,#50,#da,#50,#d5,#50,#d2,#90
	db #3c,#f0,#3e,#e0,#40,#d0,#42,#c0
	db #44,#b0,#46,#b0,#48,#a0,#4a,#a0
	db #4c,#90,#4e,#90,#50,#80,#52,#80
	db #54,#70,#56,#70,#58,#60,#5a,#60
	db #0e,#9f,#6b,#9d,#6b,#9b,#6b,#9a
	db #6a,#96,#69,#98,#69,#9b,#68,#9f
	db #68,#9b,#67,#99,#67,#96,#66,#92
	db #67,#8a,#65,#82,#66,#12,#5f,#8a
	db #5d,#7b,#5b,#6c,#59,#5d,#57,#4e
	db #55,#3f,#53,#2e,#51,#1e,#4f,#0d
	db #2d,#fd,#2b,#ed,#29,#dc,#27,#cc
	db #25,#bb,#23,#ab,#21,#9a,#21,#89
	db #21,#78,#14,#3f,#2f,#3f,#3f,#3f
	db #4e,#3f,#5e,#3f,#6d,#3f,#7c,#3f
	db #8d,#3f,#9c,#3f,#ab,#3f,#bc,#3f
	db #cb,#3f,#da,#3f,#e9,#3f,#fa,#5f
	db #09,#3f,#b8,#3f,#c9,#3f,#d8,#3f
	db #e7,#3f,#f8,#19,#ff,#fe,#f9,#fe
	db #f3,#ff,#fb,#ff,#ff,#ff,#f9,#fe
	db #f1,#ff,#e7,#fe,#ef,#fd,#f8,#fe
	db #ff,#fd,#ff,#fc,#f7,#fb,#f0,#fc
	db #e7,#fb,#f2,#fa,#fa,#fb,#fe,#fa
	db #fe,#fb,#fe,#fa,#fe,#fb,#fe,#fa
	db #fe,#f9,#fe,#f8,#fe,#f8,#be,#1c
	db #fc,#0e,#f6,#b8,#fb,#dc,#f5,#54
	db #fb,#aa,#f5,#f0,#fa,#78,#f5,#8c
	db #fa,#46,#f5,#28,#fa,#14,#f5,#c4
	db #f9,#e2,#f4,#60,#f9,#b0,#f4,#fc
	db #f8,#7e,#f4,#98,#f8,#4c,#f4,#34
	db #f8,#1a,#f4,#d0,#f7,#e8,#f3,#6c
	db #f7,#b6,#f3,#08,#f7,#84,#f3,#a4
	db #f6,#52,#f3,#40,#f6,#20,#f3,#dc
	db #f5,#ee,#f2,#78,#f5,#bc,#f2,#14
	db #f5,#8a,#f2,#b0,#f4,#58,#f2,#4c
	db #f4,#26,#f2,#e8,#f3,#f4,#f1,#84
	db #f3,#c2,#f1,#20,#f3,#90,#f1,#bc
	db #f2,#5e,#f1,#58,#f2,#2c,#f1,#f4
	db #f1,#fa,#f0,#90,#f1,#c8,#f0,#2c
	db #f1,#96,#f0,#c8,#f0,#64,#f0,#64
	db #f0,#32,#f0,#19,#ff,#fe,#f9,#fe
	db #f3,#ff,#fb,#ff,#ff,#ff,#f9,#fe
	db #f1,#ff,#e7,#fe,#ef,#fd,#f8,#fe
	db #ff,#fd,#ff,#fc,#f7,#fb,#f0,#fc
	db #e7,#fb,#f2,#fa,#fa,#fb,#fe,#fa
	db #fe,#fb,#fe,#fa,#fe,#fb,#fe,#fa
	db #fe,#f9,#fe,#f8,#fe,#f8,#0f,#3a
	db #2c,#3a,#3b,#3a,#4b,#3a,#5a,#3a
	db #6a,#3a,#79,#3a,#8a,#3a,#99,#3a
	db #a8,#3a,#b9,#3a,#c8,#3a,#d7,#3a
	db #e6,#3a,#f7,#5a,#06,#90,#3c,#f0
	db #3e,#e0,#40,#d0,#42,#c0,#44,#b0
	db #46,#b0,#48,#a0,#4a,#a0,#4c,#90
	db #4e,#90,#50,#80,#52,#80,#54,#70
	db #56,#70,#58,#60,#5a,#60,#0d,#59
	db #39,#57,#2a,#55,#1b,#53,#0b,#31
	db #fc,#2f,#ec,#2d,#dc,#2b,#cc,#29
	db #bb,#27,#ab,#25,#9a,#23,#8a,#21
	db #79,#12,#21,#78,#21,#89,#21,#9a
	db #23,#ab,#25,#bc,#27,#cc,#29,#dd
	db #2b,#ed,#2d,#fd,#4f,#0e,#51,#1e
	db #53,#2f,#55,#3e,#57,#4d,#59,#5c
	db #5b,#6b,#5d,#7a,#5f,#89,#21,#e1
	db #ff,#e1,#ff,#e4,#ff,#e7,#ff,#ea
	db #fe,#ed,#fe,#f0,#fe,#ed,#fe,#ea
	db #fd,#e7,#fd,#e4,#fd,#e3,#fc,#e1
	db #fc,#e3,#fb,#e7,#fb,#ea,#fa,#ed
	db #fa,#f0,#f9,#ed,#f9,#ea,#f8,#e7
	db #f8,#e4,#f8,#e1,#f8,#e4,#f7,#e7
	db #f7,#ea,#f7,#ed,#f7,#f0,#f6,#ed
	db #f6,#ea,#f6,#e7,#f6,#e4,#f5,#e1
	db #f5,#94,#64,#b0,#c8,#c0,#96,#d0
	db #2c,#f1,#64,#e0,#c8,#d0,#96,#c0
	db #2c,#b1,#64,#a0,#c8,#a0,#96,#90
	db #2c,#91,#64,#80,#c8,#80,#96,#80
	db #2c,#71,#64,#70,#c8,#70,#96,#60
	db #2c,#61,#12,#5f,#8a,#5d,#7b,#5b
	db #6c,#59,#5d,#57,#4e,#55,#3f,#53
	db #2e,#51,#1e,#4f,#0d,#2d,#fd,#2b
	db #ed,#29,#dc,#27,#cc,#25,#bb,#23
	db #ab,#21,#9a,#21,#89,#21,#78,#8a
	db #1e,#e0,#1f,#d0,#20,#c0,#21,#b0
	db #22,#a0,#23,#a0,#24,#90,#25,#90
	db #26,#80,#27,#80,#be,#78,#f5,#bc
	db #f2,#14,#f5,#8a,#f2,#b0,#f4,#58
	db #f2,#4c,#f4,#26,#f2,#e8,#f3,#f4
	db #f1,#84,#f3,#c2,#f1,#20,#f3,#90
	db #f1,#bc,#f2,#5e,#f1,#58,#f2,#2c
	db #f1,#f4,#f1,#fa,#f0,#90,#f1,#c8
	db #f0,#2c,#f1,#96,#f0,#c8,#f0,#64
	db #f0,#64,#f0,#32,#f0,#e8,#b3,#f4
	db #b1,#84,#b3,#c2,#b1,#20,#b3,#90
	db #b1,#bc,#b2,#5e,#b1,#58,#b2,#2c
	db #b1,#f4,#b1,#fa,#b0,#90,#b1,#c8
	db #b0,#2c,#b1,#96,#b0,#c8,#b0,#64
	db #b0,#64,#b0,#20,#93,#90,#91,#bc
	db #92,#5e,#91,#58,#92,#2c,#91,#f4
	db #91,#fa,#80,#90,#81,#c8,#80,#2c
	db #81,#96,#70,#c8,#70,#64,#70,#64
	db #70,#10,#ff,#f8,#fd,#f9,#fb,#fa
	db #f9,#fb,#f7,#fc,#f5,#fd,#f3,#fc
	db #f1,#fc,#ef,#fb,#ed,#fb,#eb,#fb
	db #e9,#fa,#e7,#fa,#e5,#f9,#e3,#f9
	db #e1,#f8,#9b,#b8,#db,#dc,#d5,#b8
	db #db,#dc,#d5,#54,#db,#aa,#d5,#f0
	db #da,#78,#d5,#8c,#ca,#46,#c5,#28
	db #ca,#14,#c5,#c4,#c9,#e2,#b4,#60
	db #b9,#b0,#b4,#b8,#bb,#54,#bb,#aa
	db #a5,#f0,#aa,#78,#a5,#8c,#aa,#46
	db #95,#28,#9a,#14,#95,#c4,#89,#e2
.l3ec5 equ $ + 1
	db #84,#0f,#0f,#0e,#0d,#0c,#0c,#0b
	db #0a,#0c,#0b,#0a,#09,#08,#08,#07
	db #06,#08,#07,#06,#05,#04,#04,#03
	db #02,#09,#0a,#0c,#0c,#0c,#0a,#0a
	db #09,#0d,#0c,#0b,#0a,#0a,#09,#08
	db #07,#0b,#0c,#0e,#0e,#0e,#0c,#0c
	db #0b,#08,#09,#0b,#0b,#0b,#09,#09
	db #08,#0f,#0f,#0f,#0e,#0d,#0c,#0b
	db #0a,#05,#04,#03,#02,#02,#01,#01
	db #00,#0e,#0e,#0d,#0b,#0b,#09,#07
.l3f15 equ $ + 1
	db #07,#00,#00,#00,#00,#00,#0f,#00
	db #00,#0c,#02,#04,#08,#10,#20,#00
	db #00,#f8,#00,#00,#08,#00,#f8,#08
	db #00,#00,#08,#10,#20,#20,#10,#08
	db #00,#18,#fe,#fc,#f8,#00,#f8,#fc
	db #fe,#18,#f4,#f4,#0c,#0c,#f4,#f4
	db #0c,#0c,#f4,#f4,#0c,#f4,#0c,#0c
	db #f4,#00,#0c,#0c,#0c,#00,#00,#0c
	db #f4,#0c,#01,#01,#ff,#ff,#ff,#01
	db #00,#30,#f4,#f4,#00,#00,#01,#ff
.l3f65 equ $ + 1
	db #ff,#ff,#fd,#50,#fd,#24,#3f,#d8
	db #04,#10,#01,#04,#00,#bf,#fa,#ef
	db #fe,#fa,#ff,#b6,#43,#54,#8a,#20
	db #00,#45,#0f,#df,#43,#f7,#02,#41
	db #00,#10,#40,#00,#10,#43,#f4,#10
	db #fd,#24,#3f,#40,#04,#10,#01,#04
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#ce,#4b,#39,#76,#4d,#93
	db #ce,#75,#48,#45,#04,#9d,#41,#36
	db #42,#bf,#6a,#c3,#08,#ba,#eb,#4b
	db #0c,#2f,#da,#fc,#42,#8d,#93,#64
	db #d5,#3c,#e7,#39,#76,#4d,#53,#64
	db #8a,#64,#e0,#83,#41,#0f,#ff,#ff
	db #06,#d5,#01,#d4,#c0,#8d,#53,#64
	db #d5,#36,#43,#ff,#ff,#ff,#ff,#50
	db #83,#79,#20,#1d,#4c,#06,#42,#bf
	db #1a,#ef,#3e,#fa,#ff,#52,#d5,#36
	db #4e,#9d,#52,#2d,#93,#54,#d9,#22
	db #a3,#08,#e0,#83,#41,#0f,#ff,#41
	db #56,#d5,#01,#d4,#c0,#54,#d9,#35
	db #4d,#93,#54,#bc,#1a,#ef,#3e,#fa
	db #ff,#d9,#3a,#75,#48,#b6,#4d,#53
	db #64,#8a,#8d,#53,#64,#d5,#36,#4d
	db #53,#64,#e9,#d5,#22,#d9,#35,#4d
	db #92,#08,#e0,#83,#41,#00,#80,#23
	db #54,#d9,#35,#48,#b6,#4d,#93,#54
	db #d9,#35,#2d,#38,#d3,#8d,#38,#20
	db #c2,#79,#04,#9d,#4c,#06,#42,#bd
	db #3a,#ef,#76,#fa,#ff,#53,#50,#8b
	db #64,#d5,#36,#40,#e0,#83,#dc,#04
	db #10,#4e,#4d,#52,#2d,#90,#35,#48
	db #36,#4d,#52,#2d,#93,#41,#e0,#83
	db #08,#90,#83,#79,#20,#1d,#41,#36
	db #42,#54,#8b,#64,#d5,#36,#4e,#08
	db #e0,#83,#dc,#04,#10,#4d,#52,#2d
	db #90,#35,#48,#36,#4d,#52,#2d,#93
	db #54,#bc,#1a,#ef,#fe,#fa,#ff,#8b
	db #64,#d5,#36,#4e,#4d,#52,#2d,#90
	db #35,#48,#36,#bc,#0a,#ef,#fe,#fa
	db #ff,#4d,#52,#2d,#93,#54,#8b,#64
	db #d5,#36,#40,#d5,#36,#4d,#52,#2d
	db #93,#54,#d9,#bf,#fa,#ef,#3e,#fa
	db #ff,#00,#0f,#c0,#fc,#03,#ff,#78
	db #0f,#c0,#fc,#03,#ff,#be,#ff,#ef
	db #ff,#8e,#3f,#3f,#ff,#ff,#fc,#20
	db #cd,#3f,#fe,#2e,#fc,#a0,#4f,#bb
	db #ff,#ff,#ff,#ff,#ff,#35,#48,#4c
	db #c1,#86,#7e,#03,#64,#87,#54,#83
	db #64,#cd,#04,#00,#2c,#04,#c2,#4c
	db #ea,#c5,#c1,#d4,#c0,#bf,#fd,#af
	db #4e,#fa,#ff,#d5,#36,#48,#b5,#4d
	db #92,#0c,#b3,#47,#30,#d0,#cf,#79
	db #20,#1d,#4f,#4a,#c5,#bd,#7a,#ef
	db #3e,#fc,#7f,#d4,#38,#21,#91,#36
	db #48,#04,#24,#10,#41,#04,#00,#08
	db #ea,#c5,#c1,#d4,#c0,#bf,#f1,#6f
	db #4e,#fa,#ff,#5d,#52,#8d,#93,#54
	db #d9,#22,#d5,#36,#48,#2d,#43,#ff
	db #ff,#ff,#fd,#b0,#c2,#83,#61,#87
	db #54,#d9,#27,#1c,#e3,#8d,#1c,#20
	db #5f,#14,#da,#c5,#51,#37,#40,#bf
	db #f2,#2f,#4a,#fa,#ff,#87,#54,#76
	db #42,#2d,#50,#41,#e3,#8b,#80,#e3
	db #92,#55,#b0,#13,#77,#7a,#c5,#bf
	db #0a,#ef,#3a,#fd,#bf,#d9,#2d,#42
	db #82,#58,#62,#41,#04,#00,#ff,#ff
	db #ff,#a0,#d9,#0d,#53,#64,#d5,#36
	db #4d,#53,#64,#b5,#0c,#ff,#ff,#ff
	db #ff,#ff,#ff,#bc,#7a,#ef,#3e,#fc
	db #7f,#61,#4d,#92,#1d,#53,#64,#65
	db #04,#00,#2c,#00,#c2,#d5,#36,#4d
	db #53,#64,#b5,#0d,#86,#44,#d9,#21
	db #75,#4a,#36,#4d,#53,#64,#8b,#54
	db #d9,#20,#b5,#0e,#0d,#92,#1d,#53
	db #64,#9e,#1d,#51,#d9,#08,#8d,#53
	db #64,#41,#10,#a1,#3c,#e3,#92,#b5
	db #0a,#09,#61,#8a,#83,#64,#87,#54
	db #d9,#35,#4d,#92,#2d,#53,#64,#b5
	db #0e,#07,#50,#d8,#21,#85,#61,#c0
	db #04,#10,#41,#03,#d0,#5c,#04,#10
	db #41,#03,#d0,#7d,#0f,#ff,#fd,#20
	db #cd,#7d,#0e,#2e,#fd,#a0,#4f,#85
	db #61,#85,#61,#85,#40
;
.play_music
;
	ld hl,l465e
	ld de,l465f
	ld bc,#000d
	ld (hl),#00
	ldir
	ld a,#38
	ld (l4665),a
	call l42e4
	call l426b
	ld hl,l466b
	ld b,#0e
.l4216
	push bc
	ld a,b
	dec a
	ld c,(hl)
	dec hl
	ld b,#f4
	out (c),a
	ld b,#f6
	in a,(c)
	or #c0
	out (c),a
	and #3f
	out (c),a
	ld b,#f4
	out (c),c
	ld b,#f6
	ld c,a
	or #80
	out (c),a
	out (c),c
	pop bc
	djnz l4216
	ret
;
.real_init_music
;
	push af
	call l4258
	ld a,c
	ld (l3949),a
	ld a,#ff
	ld (l394a),a
	ld (l3944),a
.l424c
	;ld a,(l394a)
	;inc a
	;jr z,l424c
	defs 6,0	; modified by Megachur
	ld a,b
	ld (l3949),a
	pop af
	ret
.l4258
	xor a
	ld (l3944),a
	dec a
	ld (l3947),a
	ld (l3948),a
	ld a,(l3946)
	dec a
	ld (l3945),a
	ret
.l426b
	ld ix,l466e
	ld b,#08
.l4271
	push bc
	call l427d
	inc ix
	inc ix
	pop bc
	djnz l4271
	ret
.l427d
	ld a,(ix+#00)
	inc a
	ret z
	ld e,(ix+#01)
	ld hl,l3a08
	call l4386
	ld a,(hl)
	ld d,#00
	add hl,de
	add hl,de
	inc hl
	ld d,a
	and #7f
	inc e
	cp e
	jr nz,l429c
	ld (ix+#00),#ff
.l429c
	ld (ix+#01),e
	call l4389
	rl d
	ex de,hl
	ld hl,l4668
	jr nc,l42b9
	ld a,d
	rrca
	rrca
	rrca
	rrca
	and #0f
	cp (hl)
	ret c
	ld (hl),a
	ld (l4662),de
	ret
.l42b9
	ld a,d
	and #0f
	dec hl
	cp (hl)
	ret c
	ld (hl),a
	ld a,e
	ld (l4664),a
	rrca
	and #70
	ld e,a
	ld a,d
	rrca
	rrca
	rrca
	rrca
	and #0f
	or e
	ld e,a
	call l4383
	ld (l4660),hl
	ld a,e
	cp #7f
	ld a,#2a
	jr z,l42e0
	ld a,#28
.l42e0
	ld (l4665),a
	ret
.l42e4
	ld a,(l3944)
	and a
	ret z
	ld hl,l3945
	ld a,(l3946)
	inc (hl)
	cp (hl)
	call z,l43e6
	ld ix,l455c
	ld iy,l465e
	ld b,#03
.l42fe
	bit 7,(ix+#00)
	jr nz,l435e
	ld a,#0b
	sub b
	ld (l4334),a
	add a
	sub #10
	ld (l435a),a
	inc a
	ld (l435d),a
	ld a,(ix+#01)
	cp #0a
	jr nc,l4332
	add a
	add a
	add a
	ld d,a
	ld hl,l3ec5
	ld a,(l3946)
	cp #09
	ld a,(l3945)
	jr c,l432d
	rra
.l432d
	add d
	call l438f
	ld a,(hl)
.l4334 equ $ + 2
.l4332
	ld (iy+#00),a
	ld a,(ix+#02)
	add a
	add a
	add a
	ld d,a
	ld hl,l3f15
	ld a,(l3945)
	and #07
	add d
	call l438f
	ld a,(hl)
	bit 7,(ix+#03)
	jr z,l4366
	add (ix+#00)
	ld (ix+#00),a
	call l4383
.l435a equ $ + 2
.l4358
	ld (iy+#00),l
.l435d equ $ + 2
	ld (iy+#00),h
.l435e
	ld de,#000c
	add ix,de
	djnz l42fe
	ret
.l4366
	ld d,a
	ld a,(ix+#00)
	call l4383
	ld a,d
	add a
	add a
	ld d,h
	ld e,l
.l4372
	bit 3,d
	jr nz,l437e
	srl a
	rl e
	rl d
	jr l4372
.l437e
	call l438f
	jr l4358
.l4383
	ld hl,l45b6
.l4386
	call l438e
.l4389
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a
	ret
.l438e
	add a
.l438f
	add l
	ld l,a
	adc h
	sub l
	ld h,a
	ret
.l4395
	ld hl,l455c
	ld de,l455d
	ld bc,#0023
	ld (hl),#00
	ldir
	ld a,(l3949)
	ld hl,l394b
	call l4386
	push hl
	pop ix
	ld bc,#0006
	add hl,bc
	ld (l4580),hl
	ex de,hl
	ld l,(ix+#00)
	ld h,(ix+#01)
	ld (l4414),hl
	add hl,de
	ld (l4585),hl
	ld l,(ix+#02)
	ld h,(ix+#03)
	add hl,de
	ld (l4582),hl
	ld l,(ix+#04)
	ld h,(ix+#05)
	add hl,de
	ld (l4587),hl
	xor a
	ld (l4584),a
	ld (l4589),a
	ld (l458a),a
	ld (l441b),a
	jr l441f
.l43e6
	ld a,(l394a)
	inc a
	jr nz,l43f6
	ld (l394a),a
	ld de,#ffff
	ld (l3947),de
.l43f6
	ld (hl),#00
	ld hl,(l3947)
	inc hl
.l43fc
	ld (l3947),hl
	ld a,h
	or l
	jr z,l4395
	srl h
	rr l
	srl h
	rr l
	srl h
	rr l
	ld d,h
	ld e,l
	add hl,hl
	add hl,de
.l4414 equ $ + 1
	ld de,#0000
	sbc hl,de
	jr z,l43fc
.l441b equ $ + 1
	ld a,#00
	inc a
	and #07
.l441f
	jr nz,l4438
	ld iy,l4580
	ld hl,l4562
	call l451e
	ld hl,l456e
	call l451e
	ld hl,l457a
	call l451e
	xor a
.l4438
	ld (l441b),a
	ld ix,l455c
	ld b,#03
.l4441
	push bc
	push ix
	ld a,b
	rra
	ld a,#30
	jr nc,l444b
	xor a
.l444b
	ld (l447b),a
	pop hl
	ld bc,#000b
	add hl,bc
	ld bc,#0600
.l4456
	call l4546
	djnz l4456
	ld a,c
	bit 5,a
	jr nz,l44c2
	and #0f
	cp #09
	jr c,l4468
	sub #10
.l4468
	add (ix+#05)
	ld b,#30
	cp b
	jr c,l4475
	add b
	jr c,l4475
	sub #60
.l4475
	ld (ix+#05),a
	add #0c
.l447b equ $ + 1
	cp #00
	jr c,l4480
	add #0c
.l4480
	ld (ix+#00),a
	bit 4,c
	jr z,l44b9
	ld b,#02
	call l44f8
	cp #01
	jr c,l44ad
	jr z,l44ed
	cp #02
	jr z,l44a5
	ld b,#04
	call l44f8
	ld (ix+#02),a
	cp #05
	ccf
	sbc a
	ld (ix+#03),a
.l44a5
	ld b,#04
	call l44f8
	ld (ix+#04),a
.l44ad
	ld l,(ix+#01)
	ld h,(ix+#04)
	ld (ix+#04),l
	ld (ix+#01),h
.l44b9
	ld bc,#000c
	add ix,bc
	pop bc
	djnz l4441
	ret
.l44c2
	bit 3,a
	jr nz,l44d8
	and #07
	ld d,a
	ld b,#02
	push bc
	call l44f8
	pop bc
	add a
	add a
	add a
	or d
	add #09
	jr l4468
.l44d8
	rra
	xor c
	and #08
	xor c
	and #0f
	cp #0f
	jr z,l44e6
	call l4591
.l44e6
	ld a,#80
	ld (ix+#00),a
	jr l44b9
.l44ed
	ld a,(ix+#01)
	dec a
	and #0f
	ld (ix+#01),a
	jr l44b9
.l44f8
	push hl
	ld c,#00
	ld a,(l458a)
.l44fe
	and a
	jr z,l4510
	dec a
.l4502
	ld hl,l4590
	call l4546
	djnz l44fe
	ld (l458a),a
	ld a,c
	pop hl
	ret
.l4510
	ld iy,l4585
	ld hl,l458b
	call l451e
	ld a,#2f
	jr l4502
.l451e
	push bc
	push de
	ld e,(iy+#00)
	ld d,(iy+#01)
	ld a,(de)
	inc de
	ld (iy+#00),e
	ld (iy+#01),d
	ld c,a
	ld b,#00
	sla c
	rl b
	ex de,hl
	ld h,b
	ld l,c
	add hl,hl
	add hl,bc
	ld bc,l3f65
	add hl,bc
	ld bc,#0006
	ldir
	pop de
	pop bc
	ret
.l4546
	push hl
	rl (hl)
	dec hl
	rl (hl)
	dec hl
	rl (hl)
	dec hl
	rl (hl)
	dec hl
	rl (hl)
	dec hl
	rl (hl)
	rl c
	pop hl
	ret
.l4562 equ $ + 6
.l455d equ $ + 1
.l455c
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
.l456e equ $ + 2
	db #00,#00,#00,#00,#00,#00,#00,#00
.l457a equ $ + 6
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00
.l4587 equ $ + 7
.l4585 equ $ + 5
.l4584 equ $ + 4
.l4582 equ $ + 2
.l4580
	db #00,#00,#00,#00,#00,#00,#00,#00
.l458b equ $ + 3
.l458a equ $ + 2
.l4589 equ $ + 1
	db #00,#00,#00,#00,#00,#00,#00,#00
.l4590
	db #00
.l4591
	push hl
	push bc
	push de
	ld (l466c),a
	ld a,#ff
	ld (l467e),a
	ld hl,l466e
	ld bc,#0002
.l45a2
	ld a,(hl)
	inc a
	jr z,l45ac
	inc hl
	inc hl
	inc c
	inc c
	jr l45a2
.l45ac
	ld d,h
	ld e,l
	inc de
	dec hl
	lddr
	pop de
	pop bc
	pop hl
	ret
.l45b6
	dw #0777,#070c,#06a7,#0647
	dw #05ed,#0598,#0547,#04fc
	dw #04b4,#0470,#0431,#03f4
	dw #03bc,#0386,#0353,#0324
	dw #02f6,#02cc,#02a4,#027e
	dw #025a,#0238,#0218,#01fa
	dw #01de,#01c3,#01aa,#0192
	dw #017b,#0166,#0152,#013f
	dw #012d,#011c,#010c,#00fd
	dw #00ef,#00e1,#00d5,#00c9
	dw #00be,#00b3,#00a9,#009f
	dw #0096,#008e,#0086,#007f
	dw #0077,#0071,#006a,#0064
	dw #005f,#0059,#0054,#0050
	dw #004b,#0047,#0043,#003f
	dw #003c,#0038,#0035,#0032
	dw #002f,#002d,#002a,#0028
	dw #0026,#0024,#0022,#0020
	dw #001e,#001c,#001b,#0019
	dw #0018,#0016,#0015,#0014
	dw #0013,#0012,#0011,#0010
.l4665 equ $ + 7
.l4664 equ $ + 6
.l4662 equ $ + 4
.l4660 equ $ + 2
.l465f equ $ + 1
.l465e
	db #00,#00,#00,#00,#00,#00,#00,#00
.l466c equ $ + 6
.l466b equ $ + 5
.l4668 equ $ + 2
	db #00,#00,#00,#00,#00,#00,#00,#00
.l466e
	db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff
	db #ff,#ff,#ff,#ff,#ff,#ff,#ff,#ff
.l467e
	db #ff,#00,#09,#1c,#00,#00
;
.init_music	; added by Megachur
;
	ld b,a
	ld c,a
	jp real_init_music
;
.game_name
	db "Mega Phoenix",0
.game_year
	db "1991",0
.game_publisher
	db "Dinamic",0
.music_author
	db "",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
